package com.ruoyi.develop.lvDuxin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.lvDuxin.domain.LvDuxin;
import com.ruoyi.develop.lvDuxin.service.ILvDuxinService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 镀锌单Controller
 * @author lmm
 * @date 2025-07-18
 */
@RestController
@RequestMapping("/lvDuxin/lvDuxin")
public class LvDuxinController extends BaseController {
    @Autowired
    private ILvDuxinService lvDuxinService;

    /**
     * 查询镀锌单列表
     */
    @PreAuthorize("@ss.hasPermi('develop:LvDuxin:query')")
    @GetMapping("/list")
    public TableDataInfo list(LvDuxin entity) {
        startPage();
        List<LvDuxin> list = lvDuxinService.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 导出镀锌单列表
     */
    @PreAuthorize("@ss.hasPermi('develop:LvDuxin:export')")
    @Log(title = "镀锌单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LvDuxin entity) {
        List<LvDuxin> list = lvDuxinService.selectList(entity);
        ExcelUtil<LvDuxin> util = new ExcelUtil<LvDuxin>(LvDuxin. class);
        util.exportExcel(response, list, "镀锌单数据");
    }

    /**
     * 获取镀锌单详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:LvDuxin:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(lvDuxinService.selectById(id));
    }

    /**
     * 新增镀锌单
     */
    @PreAuthorize("@ss.hasPermi('develop:LvDuxin:add')")
    @Log(title = "镀锌单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody LvDuxin entity) {
        return toAjax(lvDuxinService.insert(entity));
    }

    /**
     * 修改镀锌单
     */
    @PreAuthorize("@ss.hasPermi('develop:LvDuxin:edit')")
    @Log(title = "镀锌单", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody LvDuxin entity) {
        return toAjax(lvDuxinService.update(entity));
    }

    /**
     * 删除镀锌单
     */
    @PreAuthorize("@ss.hasPermi('develop:LvDuxin:remove')")
    @Log(title = "镀锌单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(lvDuxinService.deleteByIds(ids));
    }

    /**
     * 新增镀锌单
     */
    @PreAuthorize("@ss.hasPermi('develop:LvDuxin:add')")
    @Log(title = "镀锌单和镀锌明细新增", businessType = BusinessType.INSERT)
    @PostMapping("/addDetail")
    public AjaxResult addDetail(@RequestBody LvDuxin entity) {
        return toAjax(lvDuxinService.addDetail(entity));
    }

    /**
     * 新增镀锌单明细
     */
    @PreAuthorize("@ss.hasPermi('develop:LvDuxindetail:add')")
    @Log(title = "根据镀锌单修改镀锌单明细", businessType = BusinessType.INSERT)
    @PostMapping("/uodateDetail")
    public AjaxResult uodateDetail(@RequestBody LvDuxin entity) {
        return toAjax(lvDuxinService.uodateDetail(entity));
    }

}
